package se.ytterman.jserial.framework.messaging;

import java.lang.*;
import java.util.*;

import se.ytterman.jserial.framework.device.*;

public abstract class Event {
    
    public Event() {
        this.eventParameters = new HashMap <String, Object> ();        
    } 
    
    public void addParameter(String parameterName,
                             Object parameterValue) {
        // Add new value
        this.eventParameters.put(parameterName, parameterValue);
    }
    
    public void setParameter(String parameterName, 
                             Object parameterValue) {
        // Change present value
        this.eventParameters.put(parameterName, parameterValue);
    }
      
    public void deleteParameter(String parameterName) {
        // Remove parameter
        this.eventParameters.remove(parameterName);
    }
    
    public Object getParameter(String parameterName) {
        return this.eventParameters.get(parameterName);
    }
    
    public Class getParameterType(String parameterName) {
        // Fetch object
        Object unknownObject = this.eventParameters.get(parameterName);
        
        // Fetch class of object
        Class unknownClass = unknownObject.getClass();
        
        return unknownClass;
    }
    
    public Iterator <String> getParameterNames() {
        Set <String> keySet = this.eventParameters.keySet();
        
        Iterator <String> keyIterator = keySet.iterator();
        
        return keyIterator;
    }
      
    protected HashMap <String, Object> eventParameters;
}
